package com.mz.ozy.mvp.presenter;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.MyOrderInfoBean;
import com.mz.ozy.bean.NewObExchangeBean;
import com.mz.ozy.bean.QiNiuBean;
import com.mz.ozy.bean.UploadBean;
import com.mz.ozy.constants.Constants;
import com.mz.ozy.mvp.model.ExchangeObModel;
import com.mz.ozy.mvp.model.ReturnModel;
import com.mz.ozy.mvp.view.EvaluateContract;
import com.mz.ozy.mvp.view.ExchangeObContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.net.RetrofitUtils;
import com.mz.ozy.utils.JsonUtils;
import com.mz.ozy.utils.RxUtil;
import com.mz.ozy.utils.ToastUtils;

import org.json.JSONObject;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;


public class ExchangeObPresenter extends BasePresenterImpl<ExchangeObContract.View> implements ExchangeObContract.Presenter {

    private ExchangeObModel mModel;


    public ExchangeObPresenter() {
        mModel = new ExchangeObModel();
    }

    @Override
    public void onExchange(Context context, String amt, String payPwd) {
        mModel.onExchange(context, amt, payPwd)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {

                    @Override
                    public void onSuccesss(JSONObject jsonObject) {
                        mView.onExchangeSuccess(jsonObject);
                    }
                });
    }

    @Override
    public void newOnExchange(Context context, String amt, String pwd) {
        mModel.newOnExchange(context, amt, pwd)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<NewObExchangeBean>(mView) {

                    @Override
                    public void onSuccesss(NewObExchangeBean bean) {
                        mView.newOnExchangeSuccess(bean);
                    }
                });
    }
}
